package com.turbo.cloud.ods.web.webservice;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.turbo.cloud.core.api.R;
import com.turbo.cloud.core.api.Result;
import com.turbo.cloud.core.base.PageQuery;
import com.turbo.cloud.core.validated.InsertValidated;
import com.turbo.cloud.core.validated.UpdateValidated;
import com.turbo.cloud.ods.web.logic.OdsReportSettingLogic;
import com.turbo.cloud.ods.web.model.OdsReportSettingDo;
import com.turbo.cloud.ods.web.model.OdsReportSettingQo;
import com.turbo.cloud.ods.web.model.OdsReportSettingVo;
import jakarta.validation.constraints.NotBlank;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 报表配置表 前端控制器
 * </p>
 *
 * @author zhangluning
 * @since 2024-08-07
 */
@RequiredArgsConstructor
@RestController
public class OdsReportSettingController {

    final OdsReportSettingLogic odsReportSettingLogic;

    /**
     * 查询报表配置分页列表
     *
     * @return Result
     */
    @PostMapping(name = "查询报表配置分页列表", value = "/webservice/reportSetting/queryReportSettingPage")
    public Result<Page<OdsReportSettingVo>> queryReportSettingPage(@RequestBody PageQuery<OdsReportSettingQo> pageQuery) {
        Page<OdsReportSettingVo> result = odsReportSettingLogic.queryReportSettingPage(pageQuery);
        return R.result(result);
    }

    /**
     * 根据ID查询报表配置
     *
     * @return Result
     */
    @GetMapping(name = "根据ID查询报表配置", value = "/webservice/reportSetting/queryReportSettingById")
    public Result<OdsReportSettingVo> queryReportSettingById(@RequestParam @NotBlank(message = "报表配置ID不能为空") String id) {
        OdsReportSettingVo result = odsReportSettingLogic.queryReportSettingById(id);
        return R.result(result);
    }

    /**
     * 新增报表配置
     *
     * @param umsOdsReportSettingDo 实体
     * @return Result
     */
    @PostMapping(name = "新增报表配置", value = "/webservice/reportSetting/createOdsReportSetting")
    public Result<Boolean> createReportSetting(@RequestBody @Validated(InsertValidated.class) OdsReportSettingDo umsOdsReportSettingDo) {
        boolean result = odsReportSettingLogic.createReportSetting(umsOdsReportSettingDo);
        return R.result(result);
    }

    /**
     * 修改报表配置
     *
     * @param umsOdsReportSettingDo 实体
     * @return Result
     */
    @PostMapping(name = "修改报表配置", value = "/webservice/reportSetting/modifyReportSetting")
    public Result<Boolean> modifyReportSetting(@RequestBody @Validated(UpdateValidated.class) OdsReportSettingDo umsOdsReportSettingDo) {
        boolean result = odsReportSettingLogic.modifyReportSetting(umsOdsReportSettingDo);
        return R.result(result);
    }

    /**
     * 开启、关闭报表配置有效状态
     *
     * @param id 报表配置ID
     * @return Result
     */
    @GetMapping(name = "开启、关闭报表配置有效状态", value = "/webservice/reportSetting/enabledReportSettingStateById")
    public Result<Boolean> enabledReportSettingStateById(@RequestParam @NotBlank(message = "报表配置ID不能为空") String id) {
        boolean result = odsReportSettingLogic.enabledReportSettingStateById(id);
        return R.result(result);
    }

    /**
     * 删除报表配置
     *
     * @param id 报表配置ID
     * @return Result
     */
    @GetMapping(name = "删除报表配置", value = "/webservice/reportSetting/removeReportSettingById")
    public Result<Boolean> removeReportSettingById(@RequestParam @NotBlank(message = "报表配置ID不能为空") String id) {
        boolean result = odsReportSettingLogic.removeReportSettingById(id);
        return R.result(result);
    }
}
